package com.tfjybj.itoo.teach.provider.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dmsdbj.itoo.tool.redis.CacheExpire;
import com.tfjybj.itoo.teach.entity.CourseEntity;
import com.tfjybj.itoo.teach.entity.SchoolCalendarEntity;
import com.tfjybj.itoo.teach.model.AddCourseModel;
import com.tfjybj.itoo.teach.model.ChooseCourseModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 井朝
 * @since 1.0.8 2018年11月16日18:23:31
 */
@Repository("chooseCourseDao")
public interface ChooseCourseDao extends BaseMapper<ChooseCourseModel> {



    /**
     * 查询选课周的时间
     * @param semesterId
     * @return  校历选课周的实体
     */

    @Cacheable(value = "findSCByTermIdAndEventId", key = "#p0", sync = true)
    @CacheExpire(expire = 120)
    SchoolCalendarEntity findSCByTermIdAndEventId(@Param("semesterId") String semesterId);

    /**
     * 查询可选公选课的list
     * @param semesterId
     * @param classId
     * @return
     */
    @Cacheable(value = "getPublicFromDB", key = "#p0", sync = true)
    @CacheExpire(expire = 120)
    List<ChooseCourseModel> getPublicFromDB(@Param("semesterId") String semesterId, @Param("classId") String classId);

    /**
     * 查询可选专选课的list
     * @param professionId
     * @param semesterId
     * @return
     */
    @Cacheable(value = "getMajorFromDB", key = "#p0", sync = true)
    @CacheExpire(expire = 120)
    List<ChooseCourseModel> getMajorFromDB(@Param("professionId") String professionId, @Param("semesterId") String semesterId);

    /**
     * 从课程池中查询出公选课和专选课的IDS
     * @param ScheduleCourseIds
     * @return
     */
    @Cacheable(value = "queryAllCourseByIds", key = "#p0", sync = true)
    @CacheExpire(expire = 120)
    List<String> queryAllCourseByIds(@Param("ScheduleCourseIds") List<String> ScheduleCourseIds);


    /**
     * 选课具体操作
     * @param addCourseModel
     * @return
     */
    Integer minusPubCourseCapacity(@Param("addCourseModel") AddCourseModel addCourseModel);
    Integer minusMajCourseCapacity(@Param("addCourseModel") AddCourseModel addCourseModel);

    /**
     * 退课具体操作
     * @param model
     * @return
     */
    Integer plusPubCourseCapacity(@Param("addCourseModel") AddCourseModel model);
    Integer pulsMajCourseCapacity(@Param("addCourseModel") AddCourseModel model);

    /**
     * 课程的类型
     * @param CourseIds
     * @return
     */
    @Cacheable(value = "queryAllCourseType", key = "#p0", sync = true)
    @CacheExpire(expire = 120)
    List<CourseEntity> queryAllCourseType(@Param("CourseIds") List<String> CourseIds);
}

